package com.caogen.cg_wl_kt.base

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.activity.result.ActivityResultLauncher
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import androidx.viewbinding.ViewBinding
import com.caogen.cg_wl_kt.databinding.FragmentDashboardBinding
import com.caogen.cg_wl_kt.utils.ToastUtils
import com.caogen.cg_wl_kt.utils.Toasts
import com.caogen.cg_wl_kt.vmodel.fragment.DashboardViewModel

/**
 * 项目名称: cg_wl_kt
 * Packages:com.caogen.cg_wl_kt.base
 * author: FSW
 * 创建日期: 2024/2/27 19:09
 * Describe:
 *
 */
abstract class BaseFragment < VB : ViewBinding,VM : BaseViewModel> :BFragment<VB, VM>(){


    open fun context(): Context {
        return requireContext()
    }

    open fun finish() {
        requireActivity().onBackPressed()
    }

    open fun toast(msg: String?) {
//        if (!TextUtils.isEmpty(msg)) {
//            runOnUi(Runnable { ToastUtils.showShortSafe(msg) })
//        }
        if (!TextUtils.isEmpty(msg)) {
            runOnUi(Runnable { Toasts.toast(context(), msg) })
        }
    }

    open fun runOnUi(runnable: Runnable?) {
        requireActivity().runOnUiThread(runnable)
    }
}